package com.banzhi.shop.activity;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.banzhi.shop.MyApp;
import com.banzhi.shop.R;
import com.banzhi.shop.base.BaseActivity;
import com.banzhi.shop.data.PartnerApplicationBean;
import com.banzhi.shop.model.CallBack.PartnerApplictionCallBack;
import com.banzhi.shop.model.Impl.PartnerApplicationImpl;
import com.banzhi.shop.utils.NoTokenUtils;
import com.banzhi.shop.utils.ToastUtils;
import com.banzhi.shop.utils.Translucent;

import org.json.JSONObject;

//审核失败
public class AuditStateFailActivity extends BaseActivity implements View.OnClickListener, PartnerApplictionCallBack {
    //  private Button mEnter;
    private ImageView mIvBackAudit;
    //  private LinearLayout mLlPass;
    private LinearLayout mLlAuditing;
    private Button mBtAuditing;
    private LinearLayout mLlFail;
    private Button mBtFail;
    private String mCheck;
    private TextView mTvDenyReason;
    private PartnerApplicationImpl mModel;
    private PartnerApplicationBean mPartnerApplicationBean;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        Translucent.setTranslucent(this);
        setContentView(R.layout.activity_audit_state_fail);
        mModel = new PartnerApplicationImpl();
        mModel.getPartnerApplicationData(this);
        initView();
        initData();
    }

    private void initView() {
        mIvBackAudit = (ImageView) findViewById(R.id.iv_back_audit);
        // mEnter = (Button) findViewById(R.i.enter);
        //mLlPass = (LinearLayout) findViewById(R.id.ll_pass);
        mLlAuditing = (LinearLayout) findViewById(R.id.ll_auditing);
        mBtAuditing = (Button) findViewById(R.id.bt_fail);
        mTvDenyReason = (TextView) findViewById(R.id.tv_deny_reason);

        //   mLlFail = (LinearLayout) findViewById(R.id.ll_fail);
        //  mBtFail = (Button) findViewById(R.id.bt_fail);


    }

    private void initData() {
        //  mEnter.setOnClickListener(this);
        //   mBtFail.setOnClickListener(this);
        mBtAuditing.setOnClickListener(this);
        mIvBackAudit.setOnClickListener(this);


    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_back_audit:
                finish();
                break;
        /*    case R.id.enter:
                //跳转到城市合伙人CityPartnerActivity
                startActivity(new Intent(this, CityPartnerActivity.class));
                break;*/
    /*        case R.id.bt_auditing:
                //跳转到我的
                startActivity(new Intent(this, MainActivity.class));
                break;*/
            case R.id.bt_fail:
                //跳转到合伙人申请
                Intent intent = new Intent(this, PartnerApplicationActivity.class);
                intent.putExtra("mCheck", "2");
                intent.putExtra("mIspay","1");
                startActivity(intent);
                break;
        }

    }

    @Override
    public void applyForPartnerSucess(Object object) {

    }

    @Override
    public void applyForPartnerError(Object object) {

    }

    @Override
    public void getPartnerApplicationSucess(Object object) {
        mPartnerApplicationBean = (PartnerApplicationBean) object;
        showView();

    }

    private void showView() {
        mTvDenyReason.setText(mPartnerApplicationBean.getDenyReason());

    }

    @Override
    public void getPartnerApplicationError(Object object) {
        JSONObject jsonObject = (JSONObject) object;
        NoTokenUtils.loginOut(this, jsonObject);
        ToastUtils.makeToastShort(jsonObject.optString("msg"));

    }

    @Override
    public void changePartnerApplicationSucess(Object object) {

    }

    @Override
    public void changePartnerApplicationError(Object object) {

    }
}
